const mongoose = require('mongoose')
mongoose.Promise = global.Promise;
// 连接mongodb
mongoose.connect('mongodb://localhost/test')
// 实例化连接对象
const db = mongoose.connection
db.on('error', console.error.bind(console, '连接错误：'))
db.once('open', (callback) => {
  console.log('MongoDB连接成功！！')
})
// 创建schema
const userSchema = new mongoose.Schema({
    email: String,
    passwd: String,
    url:String
})
// 创建model
const userModel = mongoose.model('user', userSchema) // newClass为创建或选中的集合

module.exports = userModel